<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
    
    
        public function index(){
            $UserEmail = $_POST['UserEmail'];
            $UserPassword = $_POST['UserPassword'];
            $query = $this->db->query(""
                    . "Select * "
                    . "From ".MYSQL_TABLE_PREFLIX.TABLE_USER_ACCOUNTS." "
                    . "Where UserEmail = '".$UserEmail."' AND UserPassword = "."'".$UserPassword."'") ;
            $query = $query->result_array();
            $query = $query[0];
            $this->session->set_userdata('UserInfo',$query);
            redirect(site_url());
        }
    
	public function checkuser($UserEmail = false, $UserPassword = false){
            if(!$UserEmail || !$UserPassword){
                echo "0"; return;
            }
            $UserEmail = urldecode($UserEmail);
            $query = $this->db->query(""
                    . "Select * "
                    . "From ".MYSQL_TABLE_PREFLIX.TABLE_USER_ACCOUNTS." "
                    . "Where UserEmail = '".$UserEmail."' AND UserPassword = "."'".$UserPassword."'") ;
            if($query->num_rows() > 0)
            {
                echo "1";
            }
            else{
                echo "0";
            }
	}
}

